﻿<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8"/>
    <!-- layui.css -->
    <script th:src="@{/js/jquery-2.2.4.min.js}"></script>
    <script th:src="@{/js/workutil.js}"></script>
    <link th:href="@{/plugin/layui/css/layui.css}" rel="stylesheet"/>
    <link th:href="@{/css/layui_custom.css}" rel="stylesheet"/>
</head>
<body>
<div id="articleIndexTop">
    <div class="layui-form-item" style="margin:0;margin-top:15px;">
        <div class="layui-block">
            <div class="layui-input-inline" style="margin-left: 1px;">
                <input type="text" id="keywords" autocomplete="off" class="layui-input"
                       placeholder="按姓名、账号进行搜索">
            </div>
            <div class="layui-input-inline" style="width:auto">
                <button class="layui-btn" lay-submit id="user-search">搜索</button>
            </div>
        </div>
    </div>
</div>
<div class="">
    <table class="layui-hide" id="table-userall" lay-filter="table-userall"></table>
</div>
<script type="text/html" id="barSetting">
    <a class="layui-btn layui-btn-xs" lay-event="edit">调整</a>
</script>
<!-- layui.js -->
<script th:src="@{/plugin/layui/layui.js}"></script>
<!-- layui规范化用法 -->
<script type="text/javascript">
    var table = null;
    $("#user-search").on("click", function () {
        var val = $("#keywords").val();
        table.reload("table-userall", {
            where: {
                search: val
            }
        });
    });
    layui.use('table', function () {
        table = layui.table;
        table.render({
            elem: '#table-userall'
            , url: '../user/userall'
            , cols: [[
                {field: 'id', title: 'ID'}
                , {field: 'name', title: '姓名'}
                , {field: 'account', title: '账号', sort: true}
                , {field: 'email', title: '邮箱'}
                , {field: 'phone', title: '手机'}
                , {field: 'maxProject', title: '最大项目数量', sort: true}
                , {field: 'lastLogin', title: '最后登录时间', sort: true}
                , {fixed: 'right', width: 100, align: 'center', toolbar: '#barSetting'}
            ]]
            , page: true
            ,pageauto:true
            , height:'full-75',
            row: function (item) {
                item.lastLogin = workUtils.toDate(item.lastLogin);
                return item;
            }
        });
        //监听工具条
        table.on('tool(table-userall)', function (obj) {
            var data = obj.data;
            if (obj.event === 'edit') {
                workUtils.put("id", data.id);
                workUtils.open({url: "../web/admin/useralledit.html", title: "调整配置"}, function () {
                    table.reload("table-userall");
                });
            }
        });
    });
</script>
</body>
</html>